#include<sys/wait.h>
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include<unistd.h>
#include <sys/types.h>
int main()
{
    pid_t pid;
    if((pid = fork())==-1)
    {
        perror("fork");
        exit(1);
    } 
    if ( pid == 0 )//子进程
    {
        sleep(20);
        exit(10);
    }
    else //父进程
    {
        int status;
        int ret = wait(&status);  
        if(ret==-1)
        {
            perror("wait failed");
            exit(EXIT_FAILURE);
        }
        if(WEXITSTATUS(status))
        {
            printf("Child process exited with ret:%d\n",WEXITSTATUS(status));
        }
    }

    return 0; 
}